#include "lcd.h"
#include "lcd_controller.h"
#include "lcd.h"
#define LCD_NUM 10

static p_lcd_params p_array_lcd_params[LCD_NUM];
static p_lcd_params g_p_selected_lcd_params;

int register_lcd(p_lcd_params plcdparams)
{
	int i;
	for(i = 0; i < LCD_NUM; i++)
	{
		if(!p_array_lcd_params[i])
		{
			p_array_lcd_params[i] = plcdparams;
			return i;
		}
	}
	return -1;
}

int select_lcd(char *name)
{
	int i;
	for(i = 0; i < LCD_NUM; i++)
	{
		if(p_array_lcd_params[i] && !strcmp(p_array_lcd_params[i]->name, name))
		{
			g_p_selected_lcd_params = p_array_lcd_params[i];
			return i;
		}
	}
	return -1;
}

void get_lcd_params(unsigned int *fb_base, int *xres, int *yres, int *bpp)
{
	*xres = g_p_selected_lcd_params->xres;
	*yres = g_p_selected_lcd_params->yres;
	*bpp  = g_p_selected_lcd_params->bpp;
	*fb_base = g_p_selected_lcd_params->fb_base;
}

void lcd_enable(void)
{
	lcd_controller_enable();
}

void lcd_disable(void)
{
	lcd_controller_disable();
}


void lcd_init(void)
{
	lcd_4_3_add();

	lcd_controller_add();

	select_lcd("lcd_4.3");

	select_lcd_controller("s3c2440");

	lcd_controller_init(g_p_selected_lcd_params);
}

